home *** CD-ROM | disk | FTP | other *** search
- R4utils 1.0
-
- Introduction.
- In the archive you will find three little utilities:
- - rl is a quick and dirty implementation of the Lucy-Richardson restoration
- algorithm.
- - tf performs a 2D Discrete Fourier Transform (DFT) on a R4 binary image.
- - an gives some stats on the distribuition of values in an image and its DFT.
-
- Requirements.
- An Amiga computer :)
- OS V2+
-
- RAM requirements.
- The rl utility is memory hungry: you will need about 2.5MB in order to restore
- a 256x256 R4 binary image. All the utilities are a lot faster if they can
- allocate FAST RAM.
-
- Installation.
- In the archive you will find two versions for each utility:
- - #?.881 is for 680X0+68881 systems (with X>2)
- - #?.000 is for vanilla 68000 systems
- so simply copy the version that fits your system where you want.
-
- Some information about implementation.
- Each program uses the Fast Fourier Transform (FFT) C routine I wrote, so
- they are quite slow ;) 2D FFT is really a "heavy" computation and should
- be computed only on really fast systems: don't expect to use your A500
- to compute a rl restoration with 500 iterations. Using a math coprocessor
- is zillion times faster if you have one.
-
- Q&A.
- What is the R4 image format?
- Well, R4 is not actually an image format; in fact it is basically a raw
- concatenation of 32 bit floating point values. This type of file is often
- used to store real digitised images from some instrument (e.g. the HST
- camera, HST being Hubble Space Telescope) and moreover is damn easy to
- read and write in every programming languages.
-
- How can I display R4 binary images on the Amiga?
- Until now there's only one way I know of: use my sao2pgm conversion
- utility as found on Aminet; this program is a quick hack I wrote, it
- converts R4 binary images in the PGM P5 format. On X Unix machines you
- can use SaoImage to display these files: let's hope someone will port it
- under AmigaOS, it would be much nicer :)
-
- Why are these utils shell only? and why is the interface so ugly?
- Cause I had to mantain source level compatibility with Unix and so
- I could not use Amiga specific features. :( However some standard
- Ansi functions were substituted with Exec and Dos ones where possible.
-
- Why are they so buggy?
- Well I can't tell you. I've used these utilities for several months now
- and on my system all is fine. Contact me if you have problems.
-
-
- RL.
- This utility performs the Lucy-Richardson restoration algorithm on a
- degraded image. This method is quite popular for restoration of HST
- WF/PC and FOC images. Look at ftp.stsci.edu (the HST internet home) to
- know more about this algorithm.
- The syntax is:
- rl <# iter> <width> <height> <infile> <psffile> <outfile> <adu> <noise> [<startfile>]
- where
- - <# iter> is the number of iterations
- - <width> and <height> the dimensions for the image to restore
- - <infile> the degraded image
- - <psffile> the image containing the Point Spread Function (PSF)
- - <outfile> the restored output image
- - <adu> and <noise> are values associated with noise (more on these below)
- - <startfile> is the optional image to start with
-
- Currently width and height must be equal and a power of two.
-
- Adu and noise.
- Adu is number of electrons per DataNumber(DN)
- Noise is the constant noise
- These values are used to compute the Square Chi for the pixel distribuition.
- A good rule to stop the iteration is to look at this value and stop
- when it is near 1 or when it does not change meaningfully.
-
- Startfile specification.
- If startfile is specified the rl loads it and starts the iteration
- using it; this is useful for subdividing the iteration in steps:
- the first time you run rl don't specify startfile and iterate for say 40 times,
- then look at the restored outfile...is it looking good? does the Square
- Chi seem to have converged? if yes then you have restored it, if no then
- run rl another time using the previous outfile as your new startfile and go on
- in this way.
-
- Things to look at.
- During the iteration the program prints some "markers":
- - the Square Chi and the delta from the previous value.
- - the Distance from the degraded image and the restored image and its delta.
- - the Square Norm for the restored object.
- These values are then saved in two separate ASCII files:
- - *.log contains the Square Chi,the Distance and the Square Norm
- - *.diflog contains the deltas
- where * is substituted with the outfile name. You can look at these values
- using a text editor and graph them using GnuPlot.
-
- For the mathematician.
- The degradation model used is the classical:
- g = k*o + w
- where g is the degraded image, k is the PSF, o the object, w the noise and
- the * denotes convolution.
-
- Let's call f(j) the j restored object and i(j)=k*f(j) its image.
-
- Square Norm for a generic h object is computed as:
-
- ||h||**2 = (sum(for all pixels) of h**2)**2
-
- Square Chi for j object is computed as:
-
- sqchi(j) = (sum(for all pixels) of (i(j)-g)**2/(var(i(j))))/(n-1)
-
- where n is the width*height and var(i(j)) is:
-
- var(i(j)) = (noise**2)/adu + i(j)/adu
-
- The Distance for the j image is computed as:
-
- dist(j) = ||i(j)-g||**2 / ||g||**2
-
- TF.
- This utility simply performs the 2D DFT of a given R4 binary image.
- The syntax is:
- tf <width> <height> <infile> <outfile>
- It simply loads the given <width> x <height> R4 infile, transform it and then
- saves the result in the R4 outfile.
-
- AN.
- This utility gives you some information about the distribuition of pixels
- in a R4 binary image and its DFT.
- The syntax is:
- an <width> <height> <infile>
- It basically load the given <width> x <height> R4 infile,prints values,
- transforms it,prints values for real and imaginary parts of the DFT,
- decompose each pixel value in modulus and phase (angle) and then prints
- the values for them.
- The values printed for each set are:
- - Min and Max the minimum and maximum values
- - Range = Max - Min
- - Ratio = Max / Min
- - Sum the sum for all pixels
- - Mean the mean value
- - Sigma the standard deviation from the mean
- This utility is almost useless, but sometimes it is handy: for example
- the Ratio value printed for the modulus of the DFT of a PSF is the
- so called "conditioning number", the bigger it is the more ill posed
- is the deconvolution problem.
-
- Thanks.
- I would like to thank two persons at STScI for their kindness:
- Bob Hanisch
- Rick White
-
- Credits, flames, etc.. to
- Stefano Agostinelli
- via Vesuvio 12/11
- 16134 Genova - ITALY
- IRC: arm
- E-mail: agos001@pn.itnet.it
-